﻿@model ListFormDefinitionModel

@{
    ViewBag.Title = "Forms";
}

<div class="folder">
    <div class="folder-heading">
        <div class="right">
            @Html.DropDownList("ProjectFilter", Model.GetProjects(Url))
        </div>
        <h2>@Loc("Project forms")</h2>
    </div>

    @{
        UI.Grid(Model.Forms)
            .SetEmptyText((L)"No forms")
            .AddColumn((L)"ID", f => f.FormDefinitionID, "w30")
            .AddColumn((L)"Identifier", f => f.PublicIdentifier, "w50")
            .AddColumn((L)"Name", f => f.Name)
            .AddColumn((L)"Created", f => f.Created, "w130")
            .AddColumn((L)"Type", f => f.FormType == Neptuo.Forms.Core.FormType.Form ? (L)"Form" : (L)"Inquiry", "w50")
            .AddColumn((L)"Public", f => f.PublicContent ? (L)"Yes" : (L)"No", "w30")
            .AddColumn("", f => Html.ActionLink((L)"Edit", "edit", "formdefinition", new { formDefinitionID = f.FormDefinitionID }, null)
                + " " + Html.ActionLink((L)"Fields", "fields", "formdefinition", new { formDefinitionID = f.FormDefinitionID }, null)
                + " " + Html.ActionLink((L)"Data", "formdata", "formdefinition", new { formDefinitionID = f.FormDefinitionID }, null)
                + " " + UI.DeleteLink((L)"Delete", "delete", "formdefinition", new { formDefinitionID = f.FormDefinitionID }, (L)"Opravdu smazat definici formuláře?"), "w140")
            .Render();
        
    }

    <div class="folder-foot">
        @Html.ActionLink((L)"+Create", "create", "formdefinition", new { ProjectID = Model.CurrentProjectID }, null)
        |
        @Html.ActionLink((L)" To projects", "index")
    </div>
</div>

@section JavascriptDomReady {

    $('#ProjectFilter').change(function() {
        window.location = $(this).val();
    });
}